package com.sf.algo.shortpath;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 批量多坐标处理器
 * @author Administrator
 *
 */
public class BatchCoordProcessor {
	private List<Coord> coords;
	private List<Coord> barlist;
	

	public BatchCoordProcessor(List<Coord> coords,List<Coord> barlist) {
		this.coords = coords;
		this.barlist = barlist;
	}
	public List<StartEndResult> process() {
		List<StartEndResult> result = new ArrayList<>();
		ShortPathAlgo algo = ShortPathAlgo.getInstance();
		for(Coord coord : coords) {
			for (Coord coordInner : coords) {
				if(coord.equals(coordInner)){
					continue;
				}
				MapInfo mapInfo = new MapInfo(new Node(coord),new Node(coordInner),barlist);
				StartEndResult startEndResult = algo.start(mapInfo);
				if(startEndResult != null) {
					startEndResult.setStart(coord);
					startEndResult.setEnd(coordInner);
					result.add(startEndResult);
				}
				
			}
		}
		
		return result;
	}
	public List<Coord> getCoords() {
		return coords;
	}
	public void setCoords(List<Coord> coords) {
		this.coords = coords;
	}
	
}
